1 package net.sourceforge.simplegamenet.dice;
2
3 import javax.swing.*;
4 import net.sourceforge.simplegamenet.util.proportionlayout.ProportionConstraints;
5 import net.sourceforge.simplegamenet.util.proportionlayout.ProportionLayout;
6
7 public class DiceScoreComponent extends JComponent {
8
9 private JLabel diceScoreLabel = new JLabel("");
10 private boolean enabled;
11
12 public DiceScoreComponent(boolean enabled) throws IllegalArgumentException {
13 this.enabled = enabled;
14 ProportionLayout layout = new ProportionLayout();
15 layout.appendColumn(0, 1.0);
16 layout.appendColumn(0, ProportionLayout.NO_PROPORTION);
17 layout.appendColumn(0, 1.0);
18 layout.appendRow(0, 1.0);
19 layout.appendRow(0, ProportionLayout.NO_PROPORTION);
20 layout.appendRow(0, 1.0);
21 setLayout(layout);
22 add(diceScoreLabel, new ProportionConstraints(1, 1));
23 }
24
25 public void setScoreLabel(String score) {
26 this.enabled = false;
27 setBorder(BorderFactory.createEmptyBorder());
28 diceScoreLabel.setText(score);
29 }
30
31 public int getScoreLabel() {
32 return Integer.parseInt(diceScoreLabel.getText());
33 }
34
35 public void setTotalScoreLabel(String total) {
36 diceScoreLabel.setText(total);
37 }
38
39 public boolean isEnabled() {
40 return enabled;
41 }
42
43 public void setEnabled(boolean enabled) {
44 this.enabled = enabled;
45 }
46
47 }